//https://leetcode.cn/problems/maximum-repeating-substring/description/?envType=problem-list-v2&envId=string-matching

class Solution {
public:
    int maxRepeating(string sequence, string word) 
    {
        int n=sequence.size(),m=word.size();
        if(n<m)
        return 0;

        int ret=0;
        vector<int> f(n);
        for(int i=m-1;i<n;i++)
        {
            bool istrue=true;
            for(int j=0;j<m;j++)
            {
                if(sequence[i-m+j+1]!=word[j])
                {
                    istrue=false;
                    break;
                }
            }

            if(istrue)
            f[i]=(i==m-1?0:f[i-m])+1;
            ret=max(ret,f[i]);
        }

        return ret;    
    }
};

//https://leetcode.cn/problems/container-with-most-water/description/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public:
    int maxArea(vector<int>& height) 
    {
        int left=0,right=height.size()-1;
        int ret=(right-left)*min(height[left],height[right]);
        while(left<right)
        {
            if(height[left]<height[right])
            {
                left++;
            }
            else
            {
                right--;
            }
            ret=max(ret,(right-left)*min(height[left],height[right]));
        }

        return ret;
    }
};